$(function(){
	$(".mc").css("display","none");
	$('#categorys').hover(function(){
		$(this).children('.mc').toggle();
	});
	queryList();
});

function queryList(){
	var url = '/json?action=QUERY_QUICK_ORDER_ACTION';
	$.post(url, {}, function(data){
		if(data.success){
			var list = data.root.ORDER_LIST.rs;
			$.each(list, function(i, obj){
				var divStr = [
					'<tr id="t',obj.PRODUCT_ID,'">',
					    '<td>'+ obj.PRODUCT_NO +'</td>',
					    '<td class="shopping_table_img"><i><a href="../product/file.html?id='+obj.PRODUCT_ID+'" target="blank"><img src="../upload/product/'+obj.PRODUCT_NO+'.jpg" /></a></i><p><a href="../product/file.html?id='+obj.PRODUCT_ID+'" target="blank">'+ obj.PRODUCT_NAME +'</a></p></td>',
					    '<td class="market_price">&nbsp;&nbsp;￥'+ (obj.MARKET_PRICE).toFixed(2) +'&nbsp;&nbsp;</td>',
					    '<td><span>￥'+ (obj.MEMBER_PRICE).toFixed(2) +'</span></td>',
					    '<td><em class="star sa',obj.STAR,'"></em></td>',
					     '<td>',obj.INFO,'&nbsp;</td>',
					    '<td><input type="checkbox" name="PRODUCT_ID" value="',obj.PRODUCT_ID,'" onclick="setlight(this, ',obj.PRODUCT_ID,')"/></td>',
				  	'</tr>'
				].join('');
				$('#product_list').append(divStr);
			});
		} else {
			alert(data.errors.errmsg);
		}
	}, 'json');
}

function setlight(o, id){
	var f = $(o).attr('checked');
	if(f == 'checked'){
		$('#t'+id).css('background', 'F3F3F3');
	} else {
		$('#t'+id).css('background', 'FFFFFF');
	}
}

function toCart(){
	var k = $("input[name='PRODUCT_ID']");
	var elements = [];
	$.each(k, function(i, obj){
		if(obj.checked){
			var bo = {};
			bo.id = parseInt(obj.value);
			bo.qty = 1;
			elements.push(bo);
		}
	});
	var url = '/json?action=UPDATE_PRODUCT_TO_CART_ACTION';
	$.post(url,{PRODUCT:JSON.stringify(elements)},function(data){
		if(data.success){
			location.href = 'shop/step1.html';
		}
	},'json');
}